package com.komodo.island.gdx;

import android.content.Context;
import android.os.Bundle;
import android.os.PowerManager;
import android.view.KeyEvent;

import com.badlogic.gdx.backends.android.AndroidApplication;

public class KomodoIslandActivity extends AndroidApplication {
	/** Called when the activity is first created. */

	KomodoIsland komodoIsland;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
		 PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "My Tag");
//		 wl.acquire();
//		   ..screen will stay on during this section..
//		 wl.release();

		KomodoIsland temp = (KomodoIsland) getLastNonConfigurationInstance();
		if (temp == null){
			komodoIsland = new KomodoIsland();
			komodoIsland.wl = wl;
		}
		else
			komodoIsland = temp;
		initialize(komodoIsland, true);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			// Gdx.app.log("BUTTT BACK", "DOWN");
			return false;
		}
		return super.onKeyDown(keyCode, event);
	}

	@Override
	public Object onRetainNonConfigurationInstance() {
		// TODO Auto-generated method stub
		return komodoIsland;
	}
}